package controller;

import bean.Account;
import dao.AccountDao;
import dao.impl.AccountDaoImpl;
import javafx.event.ActionEvent;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import util.FxmlUtil;

import java.net.URL;
import java.util.ResourceBundle;

public class BalanceController implements Initializable {
    public Label balance;
    private AccountDao accountDao = new AccountDaoImpl();

    public void cancelAction() {
        Stage stage = (Stage)this.balance.getScene().getWindow();
        stage.setScene(FxmlUtil.SCENE.get("main"));
        stage.setTitle("ATM - 首页");
    }

    public void logoutAction() {
        this.balance.getScene().getWindow().hide();
    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        Account account = (Account) FxmlUtil.DATA.get("account");
        float balance = accountDao.selectBalance(account.getAccNo());
        this.balance.setText(balance + "");
    }
}
